﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using System.Text;
using Elmah;


namespace OrbitOne.Elmah.Web.Services
{
    public class ErrorHandler : IErrorHandler
    {
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            LogError(error);
        }

        public bool HandleError(Exception error)
        {
            LogError(error);
            return false;
        }

        private void LogError(Exception error)
        {
            try
            {
                var log = ServicesXmlFileErrorLog.Default;
                var e = new Error(error);
                log.Log(e);
            }
            catch (Exception) { }
        }
    }
}
